package oldtests;

import static org.junit.Assert.*;

import java.io.File;

import org.junit.Test;

import bot.AutomationException;
import bot.City;
import bot.DataStorage;
import bot.FileStorage;
import bot.PageGenerator;

public class ParagraphTesting {
	private File data = new File("c:\\Users\\Jamison\\Documents\\PopulationInfo\\WisconsinData.txt");
	private DataStorage storage = new FileStorage(data);
	private String date = "2012-11-18";
	
	
	@Test
	public void pewaukeeTest(){
		String cityActual = "As of the [[census]]<ref name =\"FactFinder\">{{cite web|title=American FactFinder|url=http://factfinder2.census.gov/faces/nav/jsf/pages/index.xhtml|publisher={{URL|1=http://en.wikipedia.org/wiki/United_States_Census_Bureau|2=United States Census Bureau}}|accessdate=2012-11-18}}</ref> of 2010, there were 13,195 people, 5,410 households, and 3,883 families residing in the city. The [[population density]] was {{convert|676.7|PD/sqmi|PD/km2|1}}. There were 5,767 housing units at an average density of {{convert|295.7|/sqmi|/km2|1}}. The racial makeup of the city was 94.3% [[White (U.S. Census)|White]], 1.1% [[African American (U.S. Census)|African American]], 0.3% [[Native American (U.S. Census)|Native American]], 2.6% [[Asian (U.S. Census)|Asian]], 0.5% from [[Race (U.S. Census)|other races]], and 1.2% from two or more races. [[Hispanic (U.S. Census)|Hispanic]] or [[Latino (U.S. Census)|Latino]] of any race were 2.1% of the population.\n\n" +
						   "There were 5,410 households out of which 28.3% had children under the age of 18 living with them, 63.7% were [[Marriage|married couples]] living together, 5.6% had a female householder with no husband present, 2.5% had a male householder with no wife present, and 28.2% were non-families. 23.2% of all households were made up of individuals and 8.3% had someone living alone who was 65 years of age or older. The average household size was 2.42 and the average family size was 2.87.\n\n" + 
						   "The median age in the city was 45.3 years. 21.5% of residents were under the age of 18; 4.9% were between the ages of 18 and 24; 23% were from 25 to 44; 34.2% were from 45 to 64; and 16.3% were 65 years of age or older. The gender makeup of the city was 48.6% male and 51.4% female.";
		
		String villageActual = "As of the [[census]]<ref name =\"FactFinder\">{{cite web|title=American FactFinder|url=http://factfinder2.census.gov/faces/nav/jsf/pages/index.xhtml|publisher={{URL|1=http://en.wikipedia.org/wiki/United_States_Census_Bureau|2=United States Census Bureau}}|accessdate=2012-11-18}}</ref> of 2010, there were 8,166 people, 3,903 households, and 2,043 families residing in the village. The [[population density]] was {{convert|1977.2|PD/sqmi|PD/km2|1}}. There were 4,160 housing units at an average density of {{convert|1007.3|/sqmi|/km2|1}}. The racial makeup of the village was 92.4% [[White (U.S. Census)|White]], 1.1% [[African American (U.S. Census)|African American]], 0.2% [[Native American (U.S. Census)|Native American]], 3.9% [[Asian (U.S. Census)|Asian]], 0.1% [[Race (U.S. Census)|Pacific Islander]], 1.1% from [[Race (U.S. Census)|other races]], and 1.2% from two or more races. [[Hispanic (U.S. Census)|Hispanic]] or [[Latino (U.S. Census)|Latino]] of any race were 3.5% of the population.\n\n" +
							   "There were 3,903 households out of which 24.9% had children under the age of 18 living with them, 40.0% were [[Marriage|married couples]] living together, 8.8% had a female householder with no husband present, 3.5% had a male householder with no wife present, and 47.7% were non-families. 41.3% of all households were made up of individuals and 15.8% had someone living alone who was 65 years of age or older. The average household size was 2.08 and the average family size was 2.87.\n\n" +
							   "The median age in the village was 41.4 years. 20.8% of residents were under the age of 18; 6.5% were between the ages of 18 and 24; 27.8% were from 25 to 44; 28.5% were from 45 to 64; and 16.4% were 65 years of age or older. The gender makeup of the village was 47.1% male and 52.9% female.";
		
		City city = new City("http://en.wikipedia.org/w/index.php?title=Pewaukee,_Wisconsin&action=edit", storage);
		City village = new City("http://en.wikipedia.org/w/index.php?title=Pewaukee_(village),_Wisconsin&action=edit", storage);
		PageGenerator page = new PageGenerator();
		assertEquals(cityActual, page.getDemographicsParagraph(city, date));
		assertEquals(villageActual, page.getDemographicsParagraph(village, date));
		
		cityActual = "According to the [[United States Census Bureau]], the city has a total area of {{convert|21.15|sqmi|sqkm|2}}, of which, {{convert|19.50|sqmi|sqkm|2}} is land and {{convert|1.65|sqmi|sqkm|2}} is water.<ref name =\"Gazetteer files\">{{cite web|title=US Gazetteer files 2010|url=http://www.census.gov/geo/www/gazetteer/files/Gaz_places_national.txt|publisher={{URL|1=http://en.wikipedia.org/wiki/United_States_Census_Bureau|2=United States Census Bureau}}|accessdate=2012-11-18}}</ref>";
		villageActual = "According to the [[United States Census Bureau]], the village has a total area of {{convert|4.53|sqmi|sqkm|2}}, of which, {{convert|4.13|sqmi|sqkm|2}} is land and {{convert|0.40|sqmi|sqkm|2}} is water.<ref name =\"Gazetteer files\">{{cite web|title=US Gazetteer files 2010|url=http://www.census.gov/geo/www/gazetteer/files/Gaz_places_national.txt|publisher={{URL|1=http://en.wikipedia.org/wiki/United_States_Census_Bureau|2=United States Census Bureau}}|accessdate=2012-11-18}}</ref>";
		assertEquals(cityActual, page.getGeoSentence(city, date));
		assertEquals(villageActual, page.getGeoSentence(village, date));
	}
	
//	@Test
//	public void replacementTest(){
//		String input = "blah blah ==Geography==\n" +
//					   "According to the 2010 census, the town has a total area of {{convert|21.15|sqmi}}, of which {{convert|19.50|sqmi}} (or 99.12%) is land and {{convert|1.65|sqmi}} (or 0.84%) is water.\n\n" +
//					   "==References==\n" +
//					   "blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah";
//		
//		String input2 = "blah blah ==Geography==\n" +
//						"According to the [[United States Census Bureau]], the town has a total area of {{convert|23.15|sqmi}}, of which {{convert|13.50|sqmi}} is land and {{convert|1.65|sqmi}} is water.\n\n" +
//						"==References==\n" +
//						"blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah";
//		
//		PageGenerator page = new PageGenerator();
//		City city = new City("http://en.wikipedia.org/w/index.php?title=Pewaukee,_Wisconsin&action=edit", storage);
//		try{
//			String result = page.setGeoSentence(input, city, date);
//			assertEquals(input, result);
//		} 
//		catch (AutomationException e){
//			e.printStackTrace();
//			assertEquals(false, true);
//		}
//		
//		try{
//			String result = page.setGeoSentence(input2, city, date);
//			String actual = "blah blah ==Geography==\n" +
//							"According to the [[United States Census Bureau]], the city has a total area of {{convert|21.15|sqmi|sqkm|2}}, of which, {{convert|19.50|sqmi|sqkm|2}} is land and {{convert|1.65|sqmi|sqkm|2}} is water.<ref name =\"Gazetteer files\">{{cite web|title=US Gazetteer files 2010|url=http://www.census.gov/geo/www/gazetteer/files/Gaz_places_national.txt|publisher={{URL|1=http://en.wikipedia.org/wiki/United_States_Census_Bureau|2=United States Census Bureau}}|accessdate=" + date + "}}</ref>\n\n" +
//							"==References==\n" +
//							"blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah";
//			assertEquals(actual, result);
//		}
//		catch (AutomationException e){
//			e.printStackTrace();
//			assertEquals(false, true);
//		}
//		
//		
//	}
//	
}
